//
//  MyOrderCarTableViewCell.m
//  DistributorAB
//
//  Created by 主事丫环 on 2019/9/28.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "MyOrderCarTableViewCell.h"

@implementation MyOrderCarTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setFrame:(CGRect)frame{
    //frame.origin.x += 10;
    //frame.origin.y += 10;
    frame.size.height -= 10;
    //frame.size.width -= 20;
    [super setFrame:frame];
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        UIView *bottomV = [[UIView alloc] init];
        bottomV.frame = CGRectMake(0, 0, KWIDTH, 97);
        bottomV.layer.cornerRadius = 10;
        bottomV.layer.masksToBounds = YES;
        [self.contentView addSubview:bottomV];
        
        UIButton *rowSelBtn = [[UIButton alloc] init];
        //rowSelBtn.backgroundColor = [UIColor redColor];
        rowSelBtn.frame = CGRectMake(3, 19, 30, 30);
        [rowSelBtn setImage:[UIImage imageNamed:@"selequyu"] forState:UIControlStateNormal];
        [rowSelBtn addTarget:self action:@selector(rowSelBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [bottomV addSubview:rowSelBtn];
        self.rowSelBtn = rowSelBtn;
        
        UIImageView *proImg = [[UIImageView alloc] init];
        proImg.frame = CGRectMake(rowSelBtn.right +3, 9, 64, 64);
        proImg.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        //[proImg setImage:imgname(@"")];
        [bottomV addSubview:proImg];
        self.proImg = proImg;
        
        UILabel *proTitLab = [[UILabel alloc] init];
        //proTitLab.backgroundColor = [UIColor greenColor];
        proTitLab.frame = CGRectMake(proImg.right +10, 11, KWIDTH-3-30-3-10-64-10, 20);
        proTitLab.text = @"文艺杨坤付款系眼睛糠爆发看就付款系眼…";
        proTitLab.font = FontSize(12);
        proTitLab.textColor = [UIColor colorWithHexString:@"#5F5F5F"];
        [bottomV addSubview:proTitLab];
        self.proTitLab = proTitLab;
        
        UILabel *typeTitLab = [[UILabel alloc] init];
        //typeTitLab.backgroundColor = [UIColor redColor];
        typeTitLab.frame = CGRectMake(proImg.right +10, proTitLab.bottom +5, 30, 20);
        typeTitLab.text = @"型号";
        typeTitLab.font = FontSize(12);
        typeTitLab.textColor = [UIColor colorWithHexString:@"#666666"];
        [bottomV addSubview:typeTitLab];
        self.typeTitLab = typeTitLab;
        
        UILabel *typeConLab = [[UILabel alloc] init];
        //typeConLab.backgroundColor = [UIColor redColor];
        typeConLab.frame = CGRectMake(typeTitLab.right +10, proTitLab.bottom +5, KWIDTH/2, 20);
        typeConLab.text = @"AD1543236";
        typeConLab.font = FontSize(12);
        typeConLab.textColor = [UIColor colorWithHexString:@"#272727"];
        [bottomV addSubview:typeConLab];
        self.typeConLab = typeConLab;
        
        UIButton *lessBtn = [[UIButton alloc] init];
        //lessBtn.backgroundColor = [UIColor redColor];
        lessBtn.frame = CGRectMake(bottomV.right - 110, typeConLab.bottom, 30, 20);
        lessBtn.layer.borderWidth = 1;
        lessBtn.layer.borderColor = [UIColor colorWithHexString:@"#979797"].CGColor;
        [lessBtn setImage:[UIImage imageNamed:@"jian_select"] forState:UIControlStateNormal];
        [lessBtn addTarget:self action:@selector(lessBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [bottomV addSubview:lessBtn];
        self.lessBtn = lessBtn;
        //这里设置的是左上和左下角
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:lessBtn.bounds   byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(2, 0)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = lessBtn.bounds;
        maskLayer.path = maskPath.CGPath;
        lessBtn.layer.mask = maskLayer;
        
        UILabel *numberLab = [[UILabel alloc] init];
        //numberLab.backgroundColor = [UIColor redColor];
        numberLab.frame = CGRectMake(lessBtn.right, typeConLab.bottom, 40, 20);
        numberLab.text = @"1";
        numberLab.font = FontSize(12);
        numberLab.textAlignment = NSTextAlignmentCenter;
        numberLab.layer.borderWidth = 1;
        numberLab.layer.borderColor = [UIColor colorWithHexString:@"#979797"].CGColor;
        numberLab.textColor = [UIColor colorWithHexString:@"#272727"];
        [bottomV addSubview:numberLab];
        self.numberLab = numberLab;
        
        UIButton *addBtn = [[UIButton alloc] init];
        //addBtn.backgroundColor = [UIColor redColor];
        addBtn.frame = CGRectMake(numberLab.right, typeConLab.bottom, 30, 20);
        addBtn.layer.borderWidth = 1;
        addBtn.layer.borderColor = [UIColor colorWithHexString:@"#979797"].CGColor;
        [addBtn setImage:[UIImage imageNamed:@"jia_select"] forState:UIControlStateNormal];
        [addBtn addTarget:self action:@selector(addBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [bottomV addSubview:addBtn];
        self.addBtn = addBtn;
        //这里设置的是左上和左下角
        UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:addBtn.bounds   byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(2, 0)];
        CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
        maskLayer1.frame = addBtn.bounds;
        maskLayer1.path = maskPath1.CGPath;
        addBtn.layer.mask = maskLayer1;
        
    }
    return self;
}

//Cell上的 选择按钮 点击事件处理
- (void)rowSelBtnAction:(UIButton *)button {
    if (self.myblock) {
        self.myblock(0,@"");//减号
    }
    
    NSLog(@"您点击了 cell上边的 选择按钮");
}

//配件数量 减号按钮点击事件
- (void)lessBtnAction:(UIButton *)button {
    if (self.myblock) {
        self.myblock(1,@"");//减号
    }
    
    NSLog(@"您点击了 减号 按钮");
}

//配件数量 加好按钮点击事件
- (void)addBtnAction:(UIButton *)button {
    if (self.myblock) {
        self.myblock(2,@"");//加好
    }
    NSLog(@"您点击了 加号 按钮");
}

@end
